package com.yrihr.wisdom.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yrihr.wisdom.entity.ColumnType;
import com.yrihr.wisdom.entity.UploadEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @ClassName : FileUploadService
 * @Description :
 * @Author : wind
 * @Date: 2020-12-01 10:26
 * @Version 1.0
 */
public interface FileUploadService extends IService<UploadEntity> {
    @Transactional(rollbackFor=Exception.class)
    Integer upload(MultipartFile[] file, String baseDir,String name,String depiction,Integer columnType) throws Exception;

    /**
     * 文件下载
     * @param response
     * @param id
     * @throws IOException
     */
    void download(HttpServletResponse response , String id) throws IOException;

    /**
     * 查询所有类型
     * @return
     */
    List<ColumnType> selectAllType();

    /**
     * 根据type查询相应的upload列表
     * @param type
     * @return
     */
    List<UploadEntity> selectUploadEntityList(Integer type);

    /**
     * 根据id查询UploadEntity信息，用作信息详情展示
     * @param id
     * @return
     */
    UploadEntity selectUploadEntityById(long id);

    /**
     * 根据解码后的数字进行检测id是否存在
     * @param id
     * @return
     */
    UploadEntity checkUploadEntityId(String id);

    /**
     * 分页查询文件上传列表
     * @param page
     * @param limit
     * @param type
     * @return
     */
    IPage<UploadEntity> selectPage(long page, long limit,Integer type);
}
